home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Technical Documentation / Sample Code / DTS.Lib & Samples / Kibitz / Sound.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-22  |  1.9 KB  |  103 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:             sound.c
  5. ** Originally from:  SoundCdev by Jeremy Bornstein
  6. ** Modified by:      Eric Soldan
  7. **
  8. ** Copyright © 1990-1992 Apple Computer, Inc.
  9. ** All rights reserved. */
  10.  
  11.  
  12.  
  13. /*****************************************************************************/
  14.  
  15.  
  16.  
  17. #include "Kibitz.h"                /* Get the Kibitz includes/typedefs, etc.    */
  18. #include "KibitzCommon.h"        /* Get the stuff in common with rez.        */
  19. #include "Kibitz.protos"        /* Get the prototypes for Kibitz.            */
  20.  
  21. #ifndef __ERRORS__
  22. #include <Errors.h>
  23. #endif
  24.  
  25. #ifndef __FILES__
  26. #include <Files.h>
  27. #endif
  28.  
  29. #ifndef __SOUND__
  30. #include <Sound.h>
  31. #endif
  32.  
  33. #ifndef __SOUNDINPUT__
  34. #include <SoundInput.h>
  35. #endif
  36.  
  37. #ifndef __UTILITIES__
  38. #include <Utilities.h>
  39. #endif
  40.  
  41.  
  42.  
  43. /*****************************************************************************/
  44. /*****************************************************************************/
  45.  
  46.  
  47.  
  48. #pragma segment Main
  49. OSErr    RecordSound(FileRecHndl frHndl)
  50. {
  51.     Handle    newSnd, oldSnd;
  52.     OSErr    err;
  53.     Point    corner = {50, 50};
  54.  
  55.     if (!(newSnd = NewHandle(31 * 1024))) return(memFullErr);
  56.  
  57.     err = SndRecord(nil, corner, siBetterQuality, &newSnd);
  58.  
  59.     if (!err) {
  60.         if (oldSnd = (*frHndl)->doc.sound) DisposHandle(oldSnd);
  61.         (*frHndl)->doc.sound = newSnd;
  62.     }
  63.     else DisposHandle(newSnd);
  64.  
  65.     return(err);
  66. }
  67.  
  68.  
  69.  
  70. /*****************************************************************************/
  71.  
  72.  
  73.  
  74. /* SoundInputAvaliable
  75. **
  76. ** Sound input is avaliable if there's a device registered… */
  77.  
  78. #pragma segment Main
  79. Boolean SoundInputAvaliable(void)
  80. {
  81.     Boolean        siPresent;
  82.     Handle        devIconHandle;
  83.     Str255        devName;
  84.     NumVersion    vers;
  85.     
  86.     siPresent = false;
  87.     
  88.     if (gSystemVersion >= 0x0700) {
  89.         vers = SndSoundManagerVersion();
  90.         if (vers.majorRev > 0) {
  91.             if (SPBGetIndexedDevice(1, devName, &devIconHandle) == noErr) {
  92.                 DisposHandle(devIconHandle);
  93.                 siPresent = true;
  94.             }
  95.         }
  96.     }
  97.  
  98.     return(siPresent);
  99. }
  100.  
  101.  
  102.  
  103.